package com.jdbc;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

/**
 * @author 惊云
 * @date 2023/8/20 9:50
 */
public class SpringJDBC {

    public static void executeSQL(String sql) {
        // 创建数据源对象
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
//        com.mysql.cj.jdbc.Driver driver = new com.mysql.jdbc.Driver();
//        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:3306/ssk_bak");
        dataSource.setUsername("root");
        dataSource.setPassword("123456");

        // 创建 JdbcTemplate 对象
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

        jdbcTemplate.execute(sql);

    }
}
